import 'package:auto_route/auto_route.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider_student/config/app_router.dart';

import 'home_tab.dart';
import 'discover_tab.dart';
import 'mine_tab.dart';

@RoutePage()
class MainScreen extends StatefulWidget {
  const MainScreen({super.key});

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  int _currentIndex = 0;

  // 在_tabs列表中添加新的标签页
  final List<Widget> _tabs = [
    const HomeTab(),
    const DiscoverTab(),
    const MineTab(),
  ];

  @override
  Widget build(BuildContext context) {
    // 在底部导航栏中添加新的项
    return AutoTabsScaffold(
      routes: const [HomeRoute(), DiscoverRoute(), MineRoute()],
      bottomNavigationBuilder: (_, tabsRouter) {
        return CupertinoTabBar(
          currentIndex: tabsRouter.activeIndex,
          onTap: tabsRouter.setActiveIndex,
          items: const [
            BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.home),
              label: '首页',
            ),
            BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.chat_bubble_2),
              label: '消息',
            ),
            BottomNavigationBarItem(
              icon: Icon(CupertinoIcons.person),
              label: '我的',
            ),
          ],
        );
      },
      // tabBar: CupertinoTabBar(
      //   items: const [
      //     BottomNavigationBarItem(icon: Icon(CupertinoIcons.home), label: '首页'),
      //     BottomNavigationBarItem(
      //       icon: Icon(CupertinoIcons.search),
      //       label: '发现',
      //     ),
      //     BottomNavigationBarItem(
      //       icon: Icon(CupertinoIcons.person_2),
      //       label: '推广用户',
      //     ),
      //     BottomNavigationBarItem(
      //       icon: Icon(CupertinoIcons.profile_circled),
      //       label: '我的',
      //     ),
      //   ],
      //   currentIndex: _currentIndex,
      //   onTap: (index) {
      //     setState(() {
      //       _currentIndex = index;
      //     });
      //   },
      // ),
      // tabBuilder: (context, index) {
      //   return _tabs[index];
      // },
    );
  }
}
